module layer_mux #(
    parameter integer LAYERI = 0,
    parameter integer DATA_WIDTH = 32
) (
    input      [DATA_WIDTH-1:0] layer_din,
    input      [           1:0] opsel,
    output reg [DATA_WIDTH-1:0] layer_dout
);

  localparam integer LayerShamt = 2 ** LAYERI;

  always @(*) begin
    case (opsel)
      2'b00: layer_dout = layer_din;
      2'b01: layer_dout = {layer_din[(DATA_WIDTH-LayerShamt-1):0], {LayerShamt{1'b0}}};
      2'b10: layer_dout = {{LayerShamt{1'b0}}, layer_din[DATA_WIDTH-1:LayerShamt]};
      2'b11:
      layer_dout = {{LayerShamt{layer_din[DATA_WIDTH-1]}}, layer_din[DATA_WIDTH-1:LayerShamt]};
      default: layer_dout = layer_din;
    endcase
  end

endmodule
